﻿USE [interlinq]
GO
/****** Object:  Table [dbo].[Product]    Script Date: 11/06/2008 18:45:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Product](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](100) NOT NULL,
	[Price] [decimal](18, 4) NOT NULL,
 CONSTRAINT [PK_Product] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Order]    Script Date: 11/06/2008 18:45:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Order](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_Order] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[OrderPosition]    Script Date: 11/06/2008 18:45:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrderPosition](
	[Id] [uniqueidentifier] NOT NULL,
	[Count] [int] NOT NULL,
	[FK_ID_Product] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_OrderPosition] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[OrderPositionByOrder]    Script Date: 11/06/2008 18:45:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrderPositionByOrder](
	[FK_ID_Order] [uniqueidentifier] NOT NULL,
	[FK_ID_OrderPosition] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_OrderPositionByOrder] PRIMARY KEY CLUSTERED 
(
	[FK_ID_Order] ASC,
	[FK_ID_OrderPosition] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_OrderPosition_Product]    Script Date: 11/06/2008 18:45:47 ******/
ALTER TABLE [dbo].[OrderPosition]  WITH CHECK ADD  CONSTRAINT [FK_OrderPosition_Product] FOREIGN KEY([FK_ID_Product])
REFERENCES [dbo].[Product] ([Id])
GO
ALTER TABLE [dbo].[OrderPosition] CHECK CONSTRAINT [FK_OrderPosition_Product]
GO
/****** Object:  ForeignKey [FK_OrderPositionByOrder_Order]    Script Date: 11/06/2008 18:45:47 ******/
ALTER TABLE [dbo].[OrderPositionByOrder]  WITH CHECK ADD  CONSTRAINT [FK_OrderPositionByOrder_Order] FOREIGN KEY([FK_ID_Order])
REFERENCES [dbo].[Order] ([Id])
GO
ALTER TABLE [dbo].[OrderPositionByOrder] CHECK CONSTRAINT [FK_OrderPositionByOrder_Order]
GO
/****** Object:  ForeignKey [FK_OrderPositionByOrder_OrderPosition]    Script Date: 11/06/2008 18:45:47 ******/
ALTER TABLE [dbo].[OrderPositionByOrder]  WITH CHECK ADD  CONSTRAINT [FK_OrderPositionByOrder_OrderPosition] FOREIGN KEY([FK_ID_OrderPosition])
REFERENCES [dbo].[OrderPosition] ([Id])
GO
ALTER TABLE [dbo].[OrderPositionByOrder] CHECK CONSTRAINT [FK_OrderPositionByOrder_OrderPosition]
GO
